use bollard::Docker;
use clap::{Parser, Subcommand};
use serde::Deserialize;

#[derive(Debug, Deserialize)]
pub struct Config {
    pub base: Base,
    pub deps: Vec<Dep>,
    #[serde(skip)]
    pub curr_path: String,
}

#[derive(Debug, Deserialize)]
pub struct Base {
    pub unix: Option<String>,
    pub network: Option<String>,
}

#[derive(Debug, Deserialize, Clone)]
pub struct Dep {
    pub name: String,
    pub image: String,
    pub network: Option<String>,
    pub envs: Option<Vec<String>>,
    pub volumes: Option<Vec<String>>,
    pub ports: Option<Vec<(String, String)>>,
    pub cmd: Option<Vec<String>>,
    pub after_cmd: Option<Vec<String>>,
    pub devices: Option<Vec<String>>,
}

#[derive(Debug, Parser)]
pub struct Args {
    #[command(subcommand)]
    pub commands: Option<Commands>,
}

#[derive(Debug, Subcommand)]
pub enum Commands {
    LoadImages,
    Start,
    Update { name: String },
    Shutdown,
    Clean,
}

pub struct DeployManager {
    pub docker: Docker,
    pub config: Config,
}

impl DeployManager {
    pub fn new(docker: Docker, config: Config) -> Self {
        Self { docker, config }
    }
}
